#coding=utf-8
'''
Created on 2013年9月4日

@author: xuben

跨服武斗数据
'''

#报名阶段
KFWD_STATE_SIGN = 20
#报名结束比赛未开始阶段
KFWD_STATE_READY = 30
#比赛阶段
KFWD_STATE_ON = 50
#比赛结束阶段
KFWD_STATE_OVER = 60

#跨服武斗状态
kfwdState = 0
#下次状态改变时间
nextStateCD = 0
#报名等级限制
levelLimit = 0
#是否可以报名
canSigned = False
#是否已报名
signed = False
#跨服认证
certifacate = ""
#玩家服务器唯一id
completedId = 0
#跨服武斗服务器地址
matchAdress = ""
#跨服武斗服务器端口
matchPort = ""

'''
初始化
'''
def init(data):
    global kfwdState
    global nextStateCD
    global levelLimit
    global canSigned
    global signed
    global certifacate
    global completedId
    global matchAdress
    global matchPort
    
    if "kfwdbaseInfo" in data:
        if "kfwdState" in data["kfwdbaseInfo"]:
            kfwdState = data["kfwdbaseInfo"]["kfwdState"]
        if "nextStateCD" in data["kfwdbaseInfo"]:
            nextStateCD = data["kfwdbaseInfo"]["nextStateCD"]
    if "signInfo" in data:
        if "canSigned" in data["signInfo"]:
            canSigned = data["signInfo"]["canSigned"]
        if "signed" in data["signInfo"]:
            signed = data["signInfo"]["signed"]
        if "certifacate" in data["signInfo"]:
            certifacate = data["signInfo"]["certifacate"]
        if "completedId" in data["signInfo"]:
            completedId = data["signInfo"]["completedId"]
        if "matchAdress" in data["signInfo"]:
            matchAdress = data["signInfo"]["matchAdress"]
        if "matchPort" in data["signInfo"]:
            matchPort = data["signInfo"]["matchPort"]
    if "levelLimit" in data:
        levelLimit = data["levelLimit"]

'''
获取跨服武斗状态描述
'''
def getKfwdStateStr():
    global kfwdState
    kfwdStateStr = ""
    if kfwdState == KFWD_STATE_SIGN:
        kfwdStateStr = "跨服武斗报名"
    elif kfwdState == KFWD_STATE_READY:
        kfwdStateStr = "跨服武斗准备"
    elif kfwdState == KFWD_STATE_ON:
        kfwdStateStr = "跨服武斗进行中"
    elif kfwdState == KFWD_STATE_OVER:
        kfwdStateStr = "跨服武斗结束"
    else:
        kfwdStateStr = "跨服未知状态:" + str(kfwdState)
    return kfwdStateStr